package com.conn3cted.phrasebook.web.mobile;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import com.conn3cted.phrasebook.domain.Person;

@Controller
public class UploadController {

	@RequestMapping(value = "photoupload", method = RequestMethod.POST)
	protected String onSubmit(@RequestParam("firstname") String firstname, @RequestParam("lastname") String lastname, @RequestParam("file") MultipartFile file) throws Exception {
 
		Person person = new Person();
		person.setFirstName(firstname);
		person.setLastName(lastname);
		person.setDob("");
		person.setOccupation("");
		person.setOrigin("");
		person.setPassword("test");
		person.setSummary("");
		person.setFile(file.getBytes());
		person.persist();
		
		return "mobile/upload";
	}
	

}
